package com.janko.springbootbase.controller.serialize;

import com.janko.springbootbase.controller.serialize.dto.Person;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @Author nyk
 * @Date 2021/3/26 11:46
 * @Version 1.0
 * @Desc
 */
public class DeserialTest {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Person pp=new Person();
        pp.index=10;
        m(pp);

//        //开始反序列化
//        File file=new File("template");
//        ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(file));
//        Person person1 = (Person) inputStream.readObject();
//        System.out.println(person1.toString());
    }

    static void m(Person person){
        synchronized (person){
            person.index++;
        }
        System.out.println(person.index);
    }
}
